package org.liuyunfeng;

import org.springframework.amqp.core.AmqpAdmin;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Component;

/**
 * @author: TanJingyu
 * @create: 2022-03-18 17:21
 **/
@SpringBootApplication
@EnableRabbit
public class RabbitConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(RabbitConsumerApplication.class, args);
    }

    @Component
    public static class BootAfter implements ApplicationRunner {
        @Autowired
        private AmqpAdmin amqpAdmin;

        @Override
        public void run(ApplicationArguments args) throws Exception {
            // 声明出我们要使用的队列
            Queue orderQueue = new Queue("test", true, false, false);
            amqpAdmin.declareQueue(orderQueue);
            Queue orderCancel = new Queue("order-cancel", true, false, false);
            amqpAdmin.declareQueue(orderCancel);

            // 声明出我们要使用的交换器


            // 交换机绑定队列
        }
    }
}

    